<%-- 
    Document   : index
    Created on : 2016-6-28, 12:09:22
    Author     : 52461
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@include file="../link.jsp"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <style>
         #tab1 td{
            padding: 4px 4px 4px 4px;
            /*padding-bottom: 4px;*/
        }
        th{
            padding:4px 4px 4px 4px;
            font:bold;
            text-align:center;
        }
    </style>
    <body ng-app="ksmcApp" ng-controller="ksmcCtrl" >
        <div>
            <button ng-click="OpenSaveModal()" class="btn"><span class="fa fa-edit"></span>增加</button>
        </div>
       <table id="tab1">
            <tr>
                <th>序号</th>
                <th>科室代码</th>
                <th>科室名称</th>
                <th>拼音码</th>
                <th>自定义码</th>
                <th>父类科室</th>
                <th>级次</th>
                <th>科室类别</th>
                <th>核算科室</th>
                <th>末级判别</th>
                <th>预交金额</th>
                <th>诊疗费</th>
                <th>口服开始时间</th>
                <th>针剂开始时间</th>
                <th></th>
            </tr>
            <tr ng-repeat="list in lists">
                <td>{{$index}}</td>
                <td>{{list.KSDM}}</td>
                <td>{{list.KSMC}}</td>
                <td>{{list.SRM1}}</td>
                <td>{{list.SRM3}}</td>
                <td>{{list.FLKSDM}}</td>
                <td>{{list.JC}}</td>
                <td>{{list.KSLB}}</td>
                <td>{{list.HSKS}}</td>
                <td>{{list.MJPB}}</td>
                <td>{{list.YJJE}}</td>
                <td>{{list.ZLF}}</td>
                <td>{{list.KFYKSSJ}}</td>
                <td>{{list.ZJKSSJ}}</td>
                <td> 
                    <button ng-click="OpenUpdateModal(list)" class="btn btn-success btn-xs"><span class="fa fa-edit"></span>修改</button>
                    <button ng-click="deletePro(list)" class="btn btn-danger btn-xs"><span class="fa fa-dedent"></span>删除</button>
                </td>
                
            </tr>
        </table>
        
          <div class="modal fade mode-x" role="dialog" aria-labelledby="gridSystemModalLabel">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close" ng-click="CloseModel()"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="gridSystemModalLabel">{{title}}科室</h4>
                    </div>
                    <div class="modal-body">
                        <form  name="profile" id="profile">
                            <table id="tab2">
                                <tr>
                                    <td style="width:120px">科室代码:</td>
                                    <td><input type="text" style="width:80px" class="form-control" ng-model="ksdm"></td>
                                    <td style="width:120px">科室名称:</td>
                                    <td><input type="text" style="width:80px" class="form-control" ng-model="ksmc"></td>
                                    <td style="width:120px">拼音码:</td>
                                    <td><input type="text" style="width:80px" class="form-control" ng-model="pym"></td>
                                    <td style="width:120px">自定义码:</td>
                                     <td><input type="text" style="width:80px" class="form-control" ng-model="zdym"></td>
                                </tr>
                                <tr>
                                    <td style="width:120px">父类科室:</td>
                                    <td><select ng-model="flksed" ng-options="flks.KSDM as flks.KSMC for flks in flkss"></select></td>
                                    <td style="width:120px">级次:</td>
                                    <td><input type="text" class="form-control" ng-model="jc"></td>
                                    <td style="width:120px">科室类别:</td>
                                    <td>
                                        <select id="kslb">
                                            <option value="1">门诊科室</option>
                                            <option value="2">病房科室</option>
                                            <option value="3">医技科室</option>
                                            <option value="4">后勤科室</option>
                                        </select></td>
                                    <td style="width:120px">核算科室:</td>
                                    <td><input type="text" class="form-control" ng-model="hsks"></td>
                                </tr>
                                <tr>
                                    <td style="width:80px">末级判别:</td>
                                    <td><input type="text" class="form-control" ng-model="mjpb"></td>
                                    <td style="width:80px">预交金额:</td>
                                    <td><input type="text" class="form-control" ng-model="yjje"></td>
                                    <td style="width:80px">诊疗费:</td>
                                    <td><input type="text" class="form-control" ng-model="zlf"></td>
                                    <td style="width:80px">口服开始时间:</td>
                                    <td><input type="text" class="form-control" ng-model="kfkssj"></td>
                                </tr>
                                <tr>
                                    <td style="width:80px">针剂开始时间:</td>
                                    <td><input type="text" class="form-control" ng-model="jjkssj"></td>
                                </tr>
                            </table>
                                
                            
                            
                            
                        </form>

                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal" ng-click="CloseModel()">关闭</button>
                        <button  ng-click="checkKsdm()"  type="button" class="btn btn-primary"><span class="fa fa-save"></span>&nbsp;&nbsp;保存</button>
                    </div>
                </div><!-- /.modal-content -->
            </div><!-- /.modal-dialog -->
        </div><!-- /.modal -->
    </body>
</html>
<script>
    angular.module("ksmcApp", [])
            .controller("ksmcCtrl", function ($scope) {
                $scope.getKsdm=function(){ //获取科室列表
                    $.post("ksmc/getKsmc",function(data){
                        $scope.lists=data;
                        $scope.$apply();
                    })
                }
                $scope.getKsdm();
                $scope.getFlks=function(){ //获取父类科室
                    $.post("ksmc/getFlks",function(data){
                        $scope.flkss=data;
                        $scope.$apply();
                    });
                }
                $scope.getFlks();
                $scope.OpenSaveModal = function () {
                     $scope.title="新增";
                     $scope.ksdm="";
                    $(".mode-x").modal('show');
                }
                $scope.checkKsdm=function(){
                    if($scope.ksdm==null||$scope.ksdm!=""){
                        if($scope.ksmc==null|$scope.ksmc==""){
                            alert("请输入科室名称!");
                            return;
                        }
                        $.post("ksmc/checkKsdm",{ksdm:$scope.ksdm},function(data){
                            if(data=="false"){
                                $scope.saveKsdm();
                            }else{
                                alert("科室代码已存在!");
                            }
                        });
                    }else{
                        alert("请输入科室代码!");
                    }
                }
                
                $scope.saveKsdm=function(){
                    $.post("ksmc/saveKsdm",{ksdm:$scope.ksdm,ksmc:$scope.ksmc,pym:$scope.pym,zdym:$scope.zdym,flks:$scope.flks,jc:$scope.jc,
                           kslb:$scope.kslb,hsks:$scope.hsks,mjpb:$scope.mjpb,yjje:$scope.yjje,zlf:$scope.zlf,kfkssj:$scope.kfkssj,zjkssj:$scope.zjkssj},
                           function(data){
                                if(data=="true"){
                                    alert("保存成功!");
                                }else{
                                    alert("保存失败!");
                                }
                    })
                }
                
                
    })
</script>
